package com.aiyige.page.my.customer.adapter;

import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.aiyige.R;
import com.aiyige.page.my.customer.model.CustomerOrderEntity;
import com.aiyige.utils.StringUtils;
import com.aiyige.utils.TimeUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.LinkedList;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by xiachao
 */

public class CustomerOrderRecordListAdapter extends BaseQuickAdapter<CustomerOrderEntity, BaseViewHolder> {



    public CustomerOrderRecordListAdapter() {
        super(new LinkedList<CustomerOrderEntity>());
    }


    @Override
    protected void convert(BaseViewHolder helper, CustomerOrderEntity item) {
        ((MyHolder) helper).bindData(item);
    }

    @Override
    protected BaseViewHolder onCreateDefViewHolder(ViewGroup parent, int viewType) {
        BaseViewHolder baseViewHolder = new MyHolder(getItemView(R.layout.item_customer_order_remark, parent));
        return baseViewHolder;
    }


    public void onViewClicked() {

    }


    public class MyHolder extends BaseViewHolder {


        @BindView(R.id.tv_order_id_valye)
        TextView tvOrderIdValue;
        @BindView(R.id.tv_order_name_value)
        TextView tvOrderNameValue;
        @BindView(R.id.tv_order_type_value)
        TextView tvOrderTypeValue;
        @BindView(R.id.tv_pay_model_value)
        TextView tvPayModelValue;
        @BindView(R.id.tv_order_status_value)
        TextView tvOrderStatusValue;
        @BindView(R.id.tv_pay_time_value)
        TextView tvPayTimeValue;
        @BindView(R.id.tv_amount_receivable_value)
        TextView tvAmountReceivableValue;
        @BindView(R.id.tv_amount_collected_value)
        TextView tvAmountCollectedValue;

        public MyHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }


        public void bindData(final CustomerOrderEntity data) {
            tvOrderIdValue.setText(data.getOrderId());
            tvOrderNameValue.setText(data.getOrderName());
            tvOrderTypeValue.setText(data.getOrderTypeName());
            tvPayModelValue.setText(data.getPayMethodName());
            tvOrderStatusValue.setText(data.getOrderStatusName());
            tvPayTimeValue.setText(TimeUtils.dateToYYYYMMDDHHMM(data.getPayTime()));
            tvAmountReceivableValue.setText(StringUtils.priceFormat(Double.parseDouble(data.getAmountReceivable())));
            tvAmountCollectedValue.setText(StringUtils.priceFormat(Double.parseDouble(data.getAmountCollected())));
        }
    }

}
